#include <iostream>
#include <stdlib.h>
#include "Buffer.h"

using namespace std;

Buffer buffer;

void test1() {
	for (int i = 0; i < 10; i++) {
		cout << buffer.getChar();
	}
	for (int i = 0; i < 5; i++) {
		buffer.ungetChar();
	}
	cout << endl;
	for (int i = 0; i < 10; i++) {
		cout << buffer.getChar();
	}
}

void testBufferSize() {
	for (int i = 0; i < 20000; i++) {
		cout << buffer.getChar();
	}
}

void testUngetChar() {
	for (int i = 0; i < 20; i++) {
		cout << buffer.getChar();
	}
	cout << endl;
	char* tmp = new char[100];
	buffer.copyString(12, tmp);
	for (int i = 0; i <= 12; i++) {
		cout << tmp[i];
	}
}

void testWriteString() {
	buffer.writeString("Hello World!\n");
	buffer.writeString("Hello blub!\n");
	buffer.writeString("blabla World!\n");
	buffer.writeString("hihi World!\n");
	buffer.writeString("Hello tralu!\n");
	buffer.writeString("Heüäd!");
}

void testWriteString2() {
	buffer.writeString("1");
	buffer.writeString("2");
	buffer.writeString("3");
	buffer.writeString("4");
	buffer.writeString("5");
	buffer.writeString("6");
}

void testWriteString3() {
	char* tmp = new char[100];
	for (int i = 0; i < 2000000; i++) {
		for (int j = 0; j < 99; j++) {
			tmp[j] = buffer.getChar();
		}
		tmp[99] = '\0';
		buffer.writeString(tmp);
	}
}

int main(int argc, char* argv[]) {
	buffer.init("ebook.txt", "out.txt");

	//test1();
	//test2();
	//testUngetChar();

	testWriteString3();

	return EXIT_SUCCESS;
}
